package com.mylove.okhttp;

import android.content.Context;

import com.benyanyi.okhttp.OkHttpUtil;

/**
 * @author YanYi
 * @date 2019-08-19 11:15
 * @email ben@yanyi.red
 * @overview
 */
public class DownloadManager {

    private static DownloadManager instance;
    private Context context;

    public static DownloadManager getInstance(Context mContext) {
        if (instance == null) {
            instance = new DownloadManager(mContext);
        }
        return instance;
    }

    private DownloadManager(Context context) {
        this.context = context;
    }

    public void start(String url) {
        OkHttpUtil.getInstance(context).url(url).download(".apk").start();
    }

    public void cancel(String url) {
        OkHttpUtil.getInstance(context).url(url).download().cancel();
    }

}
